package com.example.learn.hwod;

import java.util.Scanner;

public class _16调整顺序 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.nextLine());

        String[] cmds = new String[n * 2];
        for (int i = 0; i < n * 2; i++) {
            cmds[i] = sc.nextLine();
        }
        System.out.println(solution(cmds));


    }

    private static int solution(String[] cmds) {
        int size=0;
        int count=0;
        boolean flag = true;
        for (int i = 0; i < cmds.length; i++) {
            String cmd = cmds[i];
            if (cmd.startsWith("head add")) {
                if(size>0&&flag){
                    flag=false;
                }
                size++;


            }else if(cmd.startsWith("tail add")) {
                size++;
            }else{
                if(!flag){
                    count++;
                    flag=true;
                }
                size--;
            }

        }
        return count;
    }
}
